package com.tjsinfo.tjsoa.system.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.json.JSONObject;

import com.tjsinfo.tjsoa.system.bo.ISystemUserBo;
import com.tjsinfo.tjsoa.system.vo.TSystemUser;

public class ResetPassWordAction extends Action{
	private ISystemUserBo systemUserBo;
	
	public ISystemUserBo getSystemUserBo() {
		return systemUserBo;
	}

	public void setSystemUserBo(ISystemUserBo systemUserBo) {
		this.systemUserBo = systemUserBo;
	}

	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		// TODO Auto-generated method stub
		Integer id = Integer.parseInt(request.getParameter("id"));
		TSystemUser systemUser =  systemUserBo.findByIdSystemUser(id);
		systemUser.setPassword("000000");
	    if (systemUserBo.updateSystemUser(systemUser)) {
	    	JSONObject object = new JSONObject();
	    	object.put("success", true);
			response.getWriter().print(object);
		} else {
			JSONObject object = new JSONObject();
	    	object.put("success", false);
			response.getWriter().print(object);
		}
		
		return null;
	}
	
}
